Example: Cartesian Heart More...
Public Member Functions | |
| CartesianHeart (const Options &opt) | |
| Actual model. | |
| CartesianHeart (CartesianHeart &p) | |
| Constructor for cloning p. | |
| virtual Space * | copy (void) |
| Copy during cloning. | |
| virtual void | constrain (const Space &_b) |
| Add constraints to current model to get next solution (not too close). | |
| virtual void | print (std::ostream &os) const |
| Print solution coordinates. | |
| Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > > | |
| ScriptBase (const Options &opt) | |
| Constructor. | |
| ScriptBase (ScriptBase &e) | |
| Constructor used for cloning. | |
| virtual void | compare (const Space &home, std::ostream &os) const |
| Compare with s. | |
| Public Member Functions inherited from Gecode::Driver::IgnoreStepOption< BaseSpace > | |
| IgnoreStepOption (const Options &) | |
| Constructor. | |
| IgnoreStepOption (BaseSpace &e) | |
| Constructor used for cloning. | |
Protected Attributes | |
| FloatVarArray | f |
| The numbers. | |
| FloatNum | step |
| Minimum distance between two solutions. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| int | main (int argc, char *argv[]) |
| Main-function. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > > | |
| static std::ostream & | select_ostream (const char *sn, std::ofstream &ofs) |
| Choose output stream according to sn. | |
| static void | run (const Options &opt, Script *s=nullptr) |
Detailed Description
Example: Cartesian Heart
There are many mathematical curves that produce heart shapes. With a good solving effort, coordinates of a filled heart shape can be computed by solving the cartesian equation:
\[x^2+2\left(y-p\times\operatorname{abs}(x)^{\frac{1}{q}}\right)^2 = 1 \]
By setting \(p=0.5\) and \(q=2\), it yields to the equation:
\[x^2+2\left(y-\frac{\operatorname{abs}(x)^{\frac{1}{2}}}{2}\right)^2 = 1 \]
To get reasonable interval starting sizes, \(x\) and \(y\) are restricted to \([-20;20]\).
Definition at line 63 of file cartesian-heart.cpp.
Constructor & Destructor Documentation
◆ CartesianHeart() [1/2]
|
inline |
Actual model.
Definition at line 71 of file cartesian-heart.cpp.
◆ CartesianHeart() [2/2]
|
inline |
Constructor for cloning p.
Definition at line 81 of file cartesian-heart.cpp.
Member Function Documentation
◆ copy()
|
inlinevirtual |
Copy during cloning.
Definition at line 86 of file cartesian-heart.cpp.
◆ constrain()
|
inlinevirtual |
Add constraints to current model to get next solution (not too close).
Definition at line 90 of file cartesian-heart.cpp.
◆ print()
|
inlinevirtual |
Print solution coordinates.
Reimplemented from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > >.
Definition at line 98 of file cartesian-heart.cpp.
Friends And Related Symbol Documentation
◆ main()
|
Main-function.
Definition at line 108 of file cartesian-heart.cpp.
Member Data Documentation
◆ f
|
protected |
The numbers.
Definition at line 66 of file cartesian-heart.cpp.
◆ step
|
protected |
Minimum distance between two solutions.
Definition at line 68 of file cartesian-heart.cpp.
The documentation for this class was generated from the following file:
- examples/cartesian-heart.cpp
