Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:11:02+00:00 2026-06-01T23:11:02+00:00

Aims: all the derived classes should inherit some default equations from their base class.

  • 0

Aims: all the derived classes should inherit some default equations from their base class. When the default equation is not valid for a derived class then it should redeclare it.

Here is a somewhat silly minimalistic example.

package Pkg

  class Equations
    Real x;
  end Equations;

  class DefaultEquations
    extends Equations;
    equation
      x = 0.0;
  end DefaultEquations;

  class Base
    replaceable DefaultEquations equations extends Equations;
  end Base;

end Pkg;

model DuplicateEquations

    import Pkg.*;

    class CustomizedClass
      extends Base;
      redeclare Equations equations;
      equation
        equations.x = 3;
    end CustomizedClass;

    CustomizedClass customized;

end DuplicateEquations; 

For some mysterious reason, the default equation is not overriden:

omc Test.mo Package.mo
class DuplicateEquations
  Real customized.equations.x;
equation
  customized.equations.x = 0.0;
  customized.equations.x = 3.0;
end DuplicateEquations;

Why is this happening? Why are both x=0 and x=3 generated?

If I comment out the package declaration I get only the expected x=3 equation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:11:04+00:00Added an answer on June 1, 2026 at 11:11 pm

    The type has to be redeclared, not the component, as pointed out by Adrian Pop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a structure which aims at storing user defined data (i.e. from a
I have the following subroutine OutputingReorderedVectors, which aims to output vectors following some pre-specified
I have a String like this: <p><span class=qlst> <span class=caption>QuickLinks</span> <ul> <li><a href=./journal/molecules/about#aims>Aims</a></li> <li><a
I've been always thinking that DOMNodeInsertedIntoDocument/DOMNodeRemovedFromDocument events should not bubble, and for me that
The post aims to summarize all pieces of information to set up a closed
I'm writing an application which aims to centralize all data related to project management
I have a very simple VS2005 deployment project that aims to install for all
I'm writing a program which aims to generate a lot of activity in Active
I am trying to design a new application which basically aims at providing biometric
I am about to start a new personal project. It aims to be a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.